package com.lyf.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lfy.service.BisOpinionService;

@Controller
@RequestMapping("opinion")
public class BisOpinionController {
	
	@Autowired
	private BisOpinionService opinionService;
	
	@RequestMapping("list")
	public String list(Model model,HttpServletRequest request,HttpSession session){
		Map<String,Object> map=new HashMap<>();
		String mobile=request.getParameter("cmobile");
		if (mobile!=null) {
			map.put("mobile", mobile);
		}
		String context=request.getParameter("context");
		if (context!=null) {
			map.put("context", context);
		}
		String startTime=request.getParameter("startTime");
		if (startTime!=null) {
			map.put("startTime", startTime);
		}
		String endTime=request.getParameter("endTime");
		if (endTime!=null) {
			map.put("endTime", endTime);
		}		
		model.addAttribute("list", opinionService.listAll(map));
		return "bis_opinion/bisopinion";  
	}
	
	@RequestMapping("delete")
	public String delete(String oid){
		opinionService.delete(oid);
		return "redirect:/opinion/list";
	}
}
